home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / comm / misc / xqsrc1_7.lzh / include / xferqint.h < prev   
C/C++ Source or Header  |  1993-03-12  |  10KB  |  368 lines

  1. /*
  2.  *    Name:                xferqint.h
  3.  *
  4.  * Description:    Private include file for xferq.library
  5.  *
  6.  * Copyright:        1992-1993 by David Jones.
  7.  *
  8.  * Distribution:
  9.  *        This program is free software; you can redistribute it and/or modify
  10.  *        it under the terms of the GNU General Public License as published by
  11.  *        the Free Software Foundation; either version 2 of the License, or
  12.  *        (at your option) any later version.
  13.  *
  14.  *        This program is distributed in the hope that it will be useful,
  15.  *        but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  *        GNU General Public License for more details.
  18.  *
  19.  *        You should have received a copy of the GNU General Public License
  20.  *        along with this program; if not, write to:
  21.  *
  22.  *                The Free Software Foundation        David Jones
  23.  *                675 Mass Ave                            6730 Tooney Drive
  24.  *                Cambridge, MA                            Orleans, Ontario
  25.  *                02139                                        K1C 6R4
  26.  *                USA                                        Canada
  27.  *
  28.  *    Usenet:    gnu@prep.ai.mit.edu                    aa457@freenet.carleton.ca
  29.  *    Fidonet:                                                1:163/109.8
  30.  *
  31.  *        $Log: $
  32.  *
  33.  */
  34.  
  35. #ifndef XFERQINT_H
  36. #define XFERQINT_H
  37.  
  38. #ifndef EXEC_TYPES_H
  39. #include <exec/types.h>
  40. #endif
  41.  
  42. #ifndef EXEC_LISTS_H
  43. #include <exec/lists.h>
  44. #endif
  45.  
  46. #ifndef EXEC_NODES_H
  47. #include <exec/nodes.h>
  48. #endif
  49.  
  50. #define    USE_PRIVATE_POOL
  51. #ifndef USE_PRIVATE_POOL
  52. #ifndef EXEC_MEMORY_H
  53. #include <exec/memory.h>
  54. #endif
  55. #endif
  56.  
  57. #ifndef UTILITY_TAGITEM_H
  58. #include <utility/tagitem.h>
  59. #endif
  60.  
  61. /*
  62. *    Work node entry
  63. *        Work nodes are used to hold attributes of files queued for
  64. *        transmission.
  65. */
  66.  
  67. struct WorkNode {
  68.     struct Node node;                /* ln_Name and ln_Pri are valid */
  69.     UWORD userFlags;                /* User accessible flags */
  70.     char *asname;                    /* Name to send file as */
  71.     struct SiteNode *site;        /* Back pointer to site node */
  72.     struct NetAddress *addr;    /* Address that node should be queued to */
  73.     UBYTE sysFlags;                /* System-use flags */
  74.     UBYTE status;                    /* Transmission status of node */
  75. };
  76.  
  77. /*
  78. *    System flags
  79. */
  80.  
  81. #define    XQ_INQUEUE        64            /* Node is in queue */
  82. #define    XQ_LOCKED        128        /* Node is locked by another */
  83.  
  84.  
  85. /*
  86. *    Site entry
  87. *        The queue database consists of a linked list of site nodes, one
  88. *        per site.  The site node is a linked list of work nodes.
  89. */
  90.  
  91. struct SiteNode {
  92.     struct MinNode node;            /* Link into global structure */
  93.     struct NetAddress *site;    /* Address that site node refers to */
  94.     struct MinList workList;    /* List of work nodes queued to site */
  95.     UWORD flags;                    /* See below */
  96.     UWORD numSessions;            /* Number of sessions up to node */
  97.     UWORD numLocks;                /* Number of nested LockMailer() calls */
  98. };
  99.  
  100. #define    XQSITE_DIRTY        1        /* needs to be written to disk */
  101. #define    XQSITE_UNREAD        2        /* needs to be read in from disk */
  102.  
  103. /*
  104. *    Error handling
  105. *        Errors are maintained on a per-process basis.  A list of these
  106. *        structures keeps the error info.  In addition, the library
  107. *        tracks which users are ARexx and which are not through this
  108. *        structure.
  109. */
  110.  
  111. struct ENode {
  112.     struct MinNode node;
  113.     struct Task *task;
  114.     ULONG error;
  115.     UWORD flags;
  116. };
  117.  
  118. #define    EN_ISREXX        1                    /* Process is spawned by ARexx */
  119.  
  120. /*
  121. *    Session structures
  122. *        A session cookie is a linked list of session nodes.  Each session
  123. *        node points to an address.  Sessions can be walked with the walk
  124. *        structure, which allows for fancy operations.
  125. */
  126.  
  127. struct Session {
  128.     struct Node node;                /* Link into global structure */
  129.     UWORD flags;                    /* See below */
  130.     struct MinList sessList;    /* List of sites */
  131. };
  132.  
  133. struct SessNode {
  134.     struct MinNode node;            /* Link into session cookie */
  135.     struct NetAddress *addr;    /* Address to which session is up */
  136. };
  137.  
  138. struct ExtSessWalk {
  139.     struct NetAddress *na;
  140.     struct SiteNode *sn;
  141.     BOOL (*func)(struct ExtSessWalk *);
  142. };
  143.  
  144.  
  145. /*
  146. *    Variable lists
  147. *
  148. *    The SNVal structure is a combination string/numeric data item where
  149. *    either or both of the string and numeric fields may be valid.
  150. *    A VarList is a linked list of named SNVal structures.
  151. */
  152.  
  153. struct SNVal {
  154.     char *str;                        /* String value */
  155.     long num;                        /* Numeric value */
  156.     short flags;                    /* Type(s) of value */
  157. };
  158.  
  159. #define    VAR_NUMERIC        1        /* numeric field is valid */
  160. #define    VAR_STRING        2        /* string field is valid */
  161.     
  162. struct VarListEntry {
  163.     struct Node node;                /* Link to varlist structure */
  164.     short nameLen;                    /* Length of name */
  165.     struct SNVal val;                /* Value of variable */
  166. };
  167.  
  168. struct VarList {
  169.     struct MinList list;
  170. };
  171.  
  172.  
  173. /*
  174. *    Address structure
  175. */
  176.  
  177. struct NetAddress {
  178.     LONG type;                        /* One of the XQNT_... types */
  179.     char *userName;                /* Name of user */
  180.     struct {
  181.         struct {
  182.             char *domain;            /* Fidonet */
  183.             char *zone;                /* Numeric quantities are stored as strings */
  184.             char *net;                /* to facilitate templates */
  185.             char *node;
  186.             char *point;
  187.         } fido;
  188.         char *machine;                /* UUCP machine name */
  189.         char *fqda;                    /* Fully qualified domain address */
  190.         char *text;                    /* Generic text */
  191.     } addr;
  192. };
  193.  
  194. #define    ADDR_MAX            8        /* Max. fields in address */
  195.  
  196. #define    ET_ERROR            0
  197. #define    ET_NUMBER        1
  198. #define    ET_ALPHA            2
  199.  
  200. /*
  201. *    Objects
  202. *        The following structure precedes all objects in memory.  It allows
  203. *        for multiple use and type identification.
  204. */
  205.  
  206. struct XfqObject {
  207.     struct MinNode link;
  208.     ULONG size;
  209.     UWORD useCount;
  210.     UWORD type;
  211. };
  212.  
  213. #define ObjectType(x) ((struct XfqObject *)(x))[-1].type
  214. #define ObjectSize(x) ((struct XfqObject *)(x))[-1].size
  215.  
  216. /*
  217.  *        Level 2/3 private data structures.
  218.  *
  219.  *    What follows are field descriptions of objects that can be examined
  220.  * or modified.  The structures relate an ARexx field name to an offset
  221.  * in the structure having a specified type.
  222.  */
  223.  
  224. struct FieldDesc {
  225.     char *name;                            /* Name of field (for ARexx) */
  226.     Tag tag;                                /* Tag item for field */
  227.     short type;                            /* Type of field */
  228.     short offset;                        /* Offset into structure */
  229. };
  230.  
  231. /* The following object types are PRIVATE! */
  232. #define    XQO_ENODE        6
  233. #define    XQO_APATH        7            /* AnchorPath */
  234. #define    XQO_SITENODE    8
  235. #define    XQO_SESSNODE    9
  236. #define    XQO_VARLIST        10
  237. #define    XQO_VLENTRY        11            /* VarListEntry */
  238. #define    XQO_MAX            12
  239.  
  240. #define    XQO_BYTE        256            /* Signed byte */
  241. #define    XQO_WORD        257            /* Signed word */
  242. #define    XQO_LONG        258            /* Long */
  243. #define    XQO_NUMSTR    259            /* KLUDGE string <-> number */
  244.  
  245. #define    XQO_OBJECT    128
  246.  
  247. #define    XODIP_OK            0            /* Data xfer OK */
  248. #define    XODIP_NOTFOUND    1            /* Item not found */
  249. #define    XODIP_ERROR        2            /* Conversion error */
  250.  
  251. /*
  252.  * All objects have the following descriptor to allow efficient
  253.  * examines, modifies and copies.
  254.  */
  255.  
  256. struct ObjectDesc {
  257.     /* Level 2 */
  258.     char *abbr;                            /* Abbreviation for ARexx cookies */
  259.     short size;                            /* Size of base */
  260.     void (*postCreate)(void *);    /* Function to call after create */
  261.     void (*preDrop)(void *);        /* Function to call before dropping */
  262.     /* Level 3 */
  263.     struct FieldDesc *fields;        /* Description of fields */
  264.     BOOL (*preExamine)(void *);    /* Function to call before examine */
  265.     BOOL (*postExamine)(void *);    /* Function to call after examine */
  266.     BOOL (*preModify)(void *);        /* Function to call before modify */
  267.     BOOL (*postModify)(void *);    /* Function to call after modify */
  268. };
  269.  
  270. /*
  271. *    Tags for all functions
  272. */
  273.  
  274. #define    XQ_WNBase        (XQ_OBASE + 0)        /* Base of WorkNode tags */
  275. #define    XQ_ADBase        (XQ_OBASE + 16)    /* Base of Address tags */
  276. #define    XQ_SSBase        (XQ_OBASE + 32)    /* Base of session tags */
  277. #define    XQ_DeathKiss    (XQ_BASE + 64)        /* Shut down NOW!!! */
  278. #define    XQ_GetCore        (XQ_BASE + 65)        /* Get memory list */
  279.  
  280. /*
  281. *    Internal functions
  282. */
  283.  
  284. ULONG InitMemory(void);
  285. void DropMemory(void);
  286.  
  287. void *AllocObject(ULONG, ULONG);
  288. void FreeObject(void *);
  289. void CoreDump(void);
  290.  
  291. void *DupObject(void *);
  292.  
  293. char *CopyStringN(char *, ULONG);
  294. char *CopyString(char *);
  295. char *NeedString(char *, ULONG);
  296. BOOL ExamObject(void *, short (*func)(), void *);
  297. void *ModifyObject(void *, short (*func)(), void *, BOOL);
  298. BOOL ExamObjectVarList(void *, struct VarList *);
  299. void *ModifyObjectVarList(void *, struct VarList *);
  300.  
  301. void NewSNVal(struct SNVal *);
  302. void SetSNValNum(struct SNVal *, long);
  303. BOOL SetSNValStr(struct SNVal *, char *, int);
  304. BOOL GetSNValNum(struct SNVal *, long *);
  305. char *GetSNValStr(struct SNVal *);
  306. void CopySNVal(struct SNVal *, struct SNVal *);
  307.  
  308. struct Node *FindNameNoCase(struct MinList *, UBYTE *);
  309. struct VarList *NewVarList(void);
  310. void EmptyVarList(struct VarList *vl);
  311. void DropVarList(struct VarList *vl);
  312. BOOL AddVarListNum(struct VarList *, char *, int, long);
  313. BOOL AddVarListStr(struct VarList *, char *, int, char *, int);
  314. BOOL GetVarListNum(struct VarList *, char *, int, long *);
  315. struct VarListEntry *FindVarList(struct VarList *, char *, int);
  316. char *GetVarListStr(struct VarList *, char *, int);
  317. struct VarList *CopyVarList(struct VarList *);
  318. short GetNumber(char *string, short base, short maxLen, long *num);
  319. short PutNumber(char *string, short base, short maxLen, long num);
  320. char *MakeString(char *string, char *template, struct VarList *list);
  321. BOOL ScanString(char *string, char *template, struct VarList *list);
  322. int GetAddrElement(char **, BOOL);
  323.  
  324. void InitErrors(void);
  325. ULONG *PeekError(void);
  326. struct ENode *FindENode(BOOL);
  327. void DropENode(struct ENode *);
  328. void Error(long);
  329. void SetErrorTags(struct TagItem *);
  330.  
  331. void InitAddress(void);
  332. BOOL CanonAddress(struct NetAddress *);
  333.  
  334. BOOL PreExamWork(struct WorkNode *);
  335. BOOL PostExamWork(struct WorkNode *);
  336. BOOL PreModifyWork(struct WorkNode *);
  337. BOOL PostModifyWork(struct WorkNode *);
  338. void SessionDownQueue(struct SiteNode *);
  339. struct SiteNode *FindSiteQueue(struct NetAddress *);
  340. struct SiteNode *NewSiteQueue(struct NetAddress *);
  341. void InitQueue(void);
  342. void DropQueue(void);
  343. void DropSiteNode(struct SiteNode *);
  344. BOOL AnyDirty(void);
  345.  
  346. void PostCreateSession(struct Session *);
  347. void PreDropSession(struct Session *);
  348.  
  349. void ScanQueue(void);
  350. void ReadQueue(struct SiteNode *);
  351. BOOL WriteQueue(struct ExtSessWalk *);
  352. char *FullPath(char *);
  353. ULONG TruncateFile(char *);
  354. void ReadConfig(void);
  355.  
  356. void InitRexx(void);
  357.  
  358. #ifdef DEBUG
  359. void kprintf(const char *, ...);
  360. int GetCount(void *);
  361. void CheckCount(char *, void *, int);
  362. #endif
  363.  
  364. ULONG __asm CallHookRes(register __a0 struct Hook *, register __a2 void *,
  365.     register __a1 void *, register __a4 void *);
  366.  
  367. #endif /* XFERQINT_H */
  368.